package com.soft.dao;

import com.soft.pojo.Goods;
import com.soft.pojo.Shop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Repository
public class GoodsDao {
    private static Map<Integer, Goods> goods = null;

    @Autowired
    private ShopDao shopDao;

    static {
        goods = new HashMap<Integer, Goods>();

        goods.put(001, new Goods(001, "mate40pro", new Shop(001, "AA")));
        goods.put(002, new Goods(002, "p50", new Shop(002, "BB")));
        goods.put(003, new Goods(003, "nova9pro", new Shop(002, "CC")));
    }

    public Collection<Goods> getAll(){
        return goods.values();
    }
    //integer效率高
    public Goods getGoodsById(Integer id){
        return goods.get(id);
    }

    public void deleteGoodsById(Integer id){
        goods.remove(id);
    }

}
